package com.mmy.dao.restaurant;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mmy.domain.restaurant.VRestaurantBase;

public interface VRestaurantBaseRepository extends JpaRepository<VRestaurantBase, Integer> {

	/* 查找条件查找 */

	@Query(value = "select *  from vRestaurantBase where (cRestaurantName like %:cRestaurantName%) and (:iZoneID = \"\" or iZoneID = :iZoneID)  and (cRate like %:cRate%)  and (:iScenicID = \"\" or iScenicID = :iScenicID)", nativeQuery = true)
	List<VRestaurantBase> findBySearch(@Param("cRestaurantName") String cRestaurantName,
			@Param("iZoneID") String strZoneID, @Param("cRate") String cRate, @Param("iScenicID") String strScenicID);

	/**
	 * 函数功能说明： 进入后台景区电子票信息页面查询景点详情信息
	 *
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人 hanxl
	 * @date 创建日期 2020.12.24
	 */
	@Query(value = "select *  from vRestaurantBase where iRestaurantID=?1", nativeQuery = true)
	VRestaurantBase findByRestaurantID(int iRestaurantID);

	/**
	 * 前台景区电子票菜单显示景区信息
	 * 
	 * @return 返回值说明
	 * @author 创建人hanxl
	 * @param iPageSize
	 * @param iTempPageNo
	 * @date 创建日期 2020.12.24
	 */
	@Query(value = "(select * from vRestaurantBase where iRestaurantID in(:lstRestID) and cRestaurantName like %:strRestName%  and left(iZoneID,4)=left(:iZoneID,4) ) "
			+ "union (select * from vRestaurantBase where iRestaurantID in(:lstRestID) and cRestaurantName like %:strRestName%  ) "
			+ "union (select * from vRestaurantBase where iRestaurantID in(:lstRestID) and left(iZoneID,4)=left(:iZoneID,4) ) "
			+ "union (select * from vRestaurantBase where iRestaurantID in(:lstRestID)) limit :iTempPageNo,:iPageSize", nativeQuery = true)
	List<VRestaurantBase> findBySearch(@Param("lstRestID") List<Integer> lstRestID, @Param("iZoneID") int iZoneID,
			@Param("strRestName") String strRestName, @Param("iTempPageNo") int iTempPageNo,
			@Param("iPageSize") int iPageSize);

}
